#include<unistd.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<errno.h>
#include<time.h>
#include<sys/select.h>
#include<string.h>
#include<stdio.h>
#include<sys/types.h>
#include<fcntl.h>
int main(int argc ,char**argv)
{
    struct timeval time;
    time.tv_sec=1;
    time.tv_usec=0;
    fd_set r_set;
    fd_set all_set;
    int fd=open("/dev/input/mouse0",O_RDONLY);
    printf("%d\n",fd);
    FD_ZERO(&all_set);
    FD_SET(fd,&all_set);
    FD_SET(0,&all_set);
    
    while (1)
    {   
        r_set=all_set;

        int ret=select(fd+1,&r_set,NULL,NULL,&time);
        if(FD_ISSET(fd,&r_set))
        {   int cor=0;
            int n=read(fd,&cor,sizeof(cor));
            printf("%d\n",n);
            perror("read出错");
            printf("鼠标=%d\n",cor);
        }
        if(FD_ISSET(0,&r_set))
        {
            char buffer[1024]={0};
            read(0,buffer,sizeof(buffer));
            printf("键盘=:%s\n",buffer);
        }
       

    }
    
    return 0;



}